1. Field of the Invention
The present invention relates to a floating point operation, and more particularly, to an apparatus and method for converting a binary floating point number into a binary integer.
2. Description of the Related Art
Generally, a floating point operation conforms to IEEE 754 standard. FIG. 1 is a diagram illustrating an 80-bit double extended precision format for the binary floating number and FIG. 2 is a diagram illustrating a 64-bit integer format.
As shown in FIG. 1, the binary floating point number is characterized by three fields: a sign 100, an exponent 110 and a fraction 120. The fraction 120 of the binary floating point number is represented as 64 bits such as 1.xxxxx . . . xxxx. The binary point of the binary floating point number must be shifted right for conversion of the binary floating point number into the binary integer. That is, a fraction of the binary floating point number must be shifted right by 63 bits, and then an exponent value of the binary floating number increases by an exponent value of `63`.
Also, the exponent value of the binary floating point number must not be a negative number. Accordingly, the binary point of the binary floating number is shifted until the exponent value of the binary floating point number is `0`.
A conversion of a binary floating point number of `1.11110000 . . . 000.*2.sup.2 ` as a decimal point number of 7.75 into a binary integer is described below.
1) If the binary point of the binary floating point number is shifted right by 63 bits, the binary floating point number is represented as `1111100000 . . . 000.*2.sup.2-63 =1111100000 . . . .000.+2.sup.-61 `.
2) The fraction of the binary floating point number is shifted right by 61 bits until the exponent value of the binary floating point number is `0`. Then, the binary floating point number is represented as `000000 . . . 0111.11*2.sup.0 `.
3) If a bit value of `.11` below the binary point is rounded, the binary floating point number is represented as `000000 . . . 1000.*2.sup.0 `.
The binary integer of `000000 . . . 1000.*2.sup.0 ` obtained through 3 steps equals a result where the fraction of the binary floating point number is shifted right by 61 bits and a bit value below the binary point is rounded. As the number of `61` is obtained by subtracting `2` from `63`, the binary floating point number needs the right-shifting of 63-N bits where N is an exponent value of a binary floating point number and a positive number. If N is above 64, an overflow is caused because the floating point number isn't represented as a 64-bit integer. There was a problem that a conventional apparatus for converting the binary floating point number into the binary integer needs a complicated hardware or complicated control circuits.